﻿using PivotCollectionTools.Xml;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

namespace PivotCollectionTools.Xml.Test
{
    
    
    /// <summary>
    ///This is a test class for FacetCollectionTest and is intended
    ///to contain all FacetCollectionTest Unit Tests
    ///</summary>
    [TestClass()]
    public class FacetCollectionTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for Item
        ///</summary>
        [TestMethod()]
        public void FacetCollection_Item_Test()
        {
            FacetCollection target = new FacetCollection();
            string facetName = "testName";
            Facet actual = new Facet(facetName);
            target.Add(actual);
            actual = target[facetName];
            
            Assert.AreEqual(facetName, actual.FacetName);
        }

        /// <summary>
        ///A test for AddTextFacet
        ///</summary>
        [TestMethod()]
        public void FacetCollection_Add_Multiple_TextFacet_Test()
        {
            FacetCollection target = new FacetCollection();
            string name = "testText";

            string value1 = "value1";
            string value2 = "value2";

            var textList = new List<string>() { value1, value2 };
            target.AddTextFacet(name, textList);

            Assert.IsTrue(target.Contains(name));
            Assert.AreEqual(target[name].Text[0].Value, value1);
            Assert.AreEqual(target[name].Text[1].Value, value2);
        }

        /// <summary>
        ///A test for AddTextFacet
        ///</summary>
        [TestMethod()]
        public void FacetCollection_AddTextFacetTest()
        {
            FacetCollection target = new FacetCollection();

            string name = "testText";
            string value1 = "value1";
            string value2 = "value2";

            target.AddTextFacet(name, value1);
            target.AddTextFacet(name, value2);

            Assert.IsTrue(target.Contains(name));
            Assert.AreEqual(target[name].Text[0].Value, value1);
            Assert.AreEqual(target[name].Text[1].Value, value2);
        }

        /// <summary>
        ///A test for AddNumber
        ///</summary>
        [TestMethod()]
        public void FacetCollection_AddNumberTest()
        {
            FacetCollection target = new FacetCollection();
            
            string name = "testDecimal";
            decimal value1 = 9.9m;
            decimal value2 = 1.1m;
            
            target.AddNumberFacet(name, value1);
            target.AddNumberFacet(name, value2);
            
            Assert.IsTrue(target.Contains(name));
            Assert.AreEqual(target[name].Number[0].Value, value1);
            Assert.AreEqual(target[name].Number[1].Value, value2);
        }

        /// <summary>
        ///A test for FacetCollection Constructor
        ///</summary>
        [TestMethod()]
        public void FacetCollection_Constructor_Test()
        {
            FacetCollection target = new FacetCollection();
            Assert.IsNotNull(target);
        }
    }
}
